#pragma once

#include <iostream>
#include <memory>
#include <vector>

// 原型基类
class Shape
{
public:
    virtual std::unique_ptr<Shape> clone() const = 0;
    virtual void draw() const = 0;
    virtual ~Shape() {}
};

// 派生类：圆形
class Circle : public Shape
{
public:
    Circle(double r) : radius(r) {}
    std::unique_ptr<Shape> clone() const override 
    {
        return std::make_unique<Circle>(*this);
    }
    void draw() const override 
    {
        std::cout << "Circle, radius: " << radius << std::endl;
    }
private:
    double radius;
};

// 派生类：方形
class Square : public Shape 
{
public:
    Square(double l) : length(l) {}
    std::unique_ptr<Shape> clone() const override 
    {
        return std::make_unique<Square>(*this);
    }
    void draw() const override
    {
        std::cout << "Square, length: " << length << std::endl;
    }
private:
    double length;
};

